const { DataTypes, Sequelize } = require("sequelize");
const sequelize = require("./sequelizeBaseConfig.js");

const Comment = sequelize.define(
  "Comment",
  {
    id: {
      type: DataTypes.BIGINT,
      comment: "ID",
      autoIncrement: true, //自增
      primaryKey: true, //主键
    },
    created_at: {
      type: DataTypes.DATE,
      comment: "创建时间",
      defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), //如果没有设置该字段的值则使用默认
    },
    updated_at: {
      type: DataTypes.DATE,
      comment: "更新时间",
      defaultValue: Sequelize.literal(
        "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
      ),
    },
    user_id: {
      type: DataTypes.BIGINT,
      comment: "用户id",
      allowNull: true,
    },
    content: {
      type: DataTypes.STRING,
      content: "评论",
      allowNull: true,
    },
    reply_user_id: {
      type: DataTypes.BIGINT,
      comment: "回复id",
      allowNull: true,
    },
    topic_id: {
      type: DataTypes.BIGINT,
      comment: "评论主题id",
      allowNull: true,
    },
    parent_id: {
      type: DataTypes.BIGINT,
      comment: "父评论id",
      allowNull: true,
    },
    type: {
      type: DataTypes.TINYINT,
      comment: "评论类型(1.文章 2.友链 3.说说)",
      allowNull: true,
    },
    is_delete: {
      type: DataTypes.TINYINT,
      comment: "是否删除(0.否 1.是)",
      allowNull: true,
    },
    is_review: {
      type: DataTypes.TINYINT,
      comment: "是否审核(0.否 1.是)",
      allowNull: true,
    },
  },
  { tableName: "comment", timestamps: false }
);

module.exports = {
  Comment,
};
